{template 'common/header'}
<script>
    document.onkeydown=function(e){
        var a=e||window.event;//加这个火狐下不会报 event is  undefind
        if (a.keyCode == 13){
            var key = $("#number_key").val();
            var f_key = $("#freight_key").val();
            if(key >= 0){
                key++;
                $("#number"+key).focus();
            }
            if (f_key >= 0) {
                f_key++;
                $("#freight"+f_key).focus();
            }
        }
    }
    window.onbeforeunload=function(e){
        var save_data = $("#save-data").val();

        if(save_data == 1){
            var url = "{php echo $this->createWebUrl('orders',array('op' => 'drop_unset_goods'))}";
            var order_id = "{$order_id}";
            $.ajax({
                type : 'post',
                url : url,
                data : {'order_id' : order_id},
                success : function(data){

                }
            });
//            var e=window.event||e;
//            e.returnValue=("是否确定退出？");
        }
    }

    $(function(){

        var difference_region = "{$difference_region}";
        if(difference_region == true){
            alert("当前订单存在到货区域与客户区域不一致的记录！");
        }
//        $("#number0").focus();
        $(".add-goods").on('click',function(){
            $("#save-data").val(2);
        });
        $(".goods-numbers").focus(function(){
            var key = $(this).attr("key");
            $("#number_key").val(key);
            $("#freight_key").val(-2);
        });
        $(".freight").focus(function(){
            var key = $(this).attr("key");
            $("#freight_key").val(key);
            $("#number_key").val(-2);
        });
        $(".goods-numbers").blur(function(){
            get_price();
        });
        $(".freight").blur(function(){
            get_price();
        });
        $(".gen-pay").blur(function(){
            get_price();
        });
        $(".had-freight").blur(function(){
            get_price();
        });
        $(".get-all-money").on('click',function(){
//            if(confirm("是否确定已经全部收款？")) {
//                var order_id = "{$order['id']}";
//                if (order_id > 0) {
//                    var url = "{php echo $this->createWebUrl('orders',array('op' => 'get_all_money'))}";
//                    $.ajax({
//                        type: 'post',
//                        url: url,
//                        data: {'order_id': order_id},
//                        success: function (data) {
//                            location.reload();
//                        }
//                    });
//                }
//            }
            var goods_ids = {$goods_ids};
            for(var i = 0; i < goods_ids.length; i++){
                var numbers = parseInt($(".number"+goods_ids[i]).val());
                var freight = parseInt($(".fre"+goods_ids[i]).val());
                var total = numbers*freight;
                if(numbers > 0 && freight > 0) {
                    $("#had-freight" + goods_ids[i]).val(total);
                }
            }
            get_price();
        });
        $(".get-name").click(function(){
            var order_goods_id = $(this).parent().parent().attr('order_goods_id');
            $("#change-goods-id").val(order_goods_id);
            $("#change-type").val('get-name');
        });
        $(".del-goods").click(function(){
            if(confirm("是否确定删除该记录？")){
                var order_goods_id = $(this).parent().parent().attr('order_goods_id');
                if(order_goods_id){
                    var url = "{php echo $this->createWebUrl('orders',array('op' => 'del_goods'))}";
                    $.ajax({
                        type : "post",
                        url : url,
                        data : {'id' : order_goods_id},
                        success : function(data){
                            if(data == 111){
                                location.reload();
                            }
                        }
                    });
                }
            }
        });
        $(".get-money").click(function(){
            if(confirm("是否确定收齐本条款项？")){
                var order_goods_id = $(this).parent().parent().attr('order_goods_id');
                if(order_goods_id){
                    var url = "{php echo $this->createWebUrl('cashier',array('op' => 'get_money'))}";
                    $.ajax({
                        type : 'post',
                        url : url,
                        data : {'type' : 'all','goods_id' : order_goods_id},
                        success : function(data){
                            if(data == 111){
                                alert("收款成功！");
                                location.reload();
                            }else{
                                alert("不能重复收款！");
                            }
                        }
                    });
                }
            }
        });
        $(".goods-region").change(function(){
            var region_id = $(this).val();
            var member_region = "{$member['region_id']}";
            var order_goods_id = $(this).parent().parent().attr('order_goods_id');
            if(region_id != member_region){
                alert("送货区域与客户区域不一致");
//                if(confirm("送货区域与客户区域不一致，是否确定修改？")){
//                    var url = "{php echo $this->createWebUrl('orders',array('op' => 'change_order_goods'))}";
//                    $.ajax({
//                        type : "post",
//                        url : url,
//                        data : {'region_id' : region_id, 'order_goods_id' : order_goods_id},
//                        success : function(data){
//                            if(data == 111){
////                                location.reload();
//                            }else{
////                            alert(data);
//                            }
//                        }
//                    });
//                }else{
//                    location.reload();
//                }
            }
        });
//        $(".cashier").change(function(){
//            var cashier = $(this).val();
//            var order_goods_id = $(this).parent().parent().attr('order_goods_id');
//                if(confirm("是否修改收款员?")){
//                    var url = "{php echo $this->createWebUrl('orders',array('op' => 'change_order_goods'))}";
//                    $.ajax({
//                        type : "post",
//                        url : url,
//                        data : {'cashier' : cashier, 'order_goods_id' : order_goods_id},
//                        success : function(data){
//                            if(data == 111){
////                                location.reload();
//                            }else{
////                            alert(data);
//                            }
//                        }
//                    });
//                }else{
//                    location.reload();
//                }
//        });
//        $(".express-no").blur(function(){
//            var express_no = $(this).val();
//            var order_goods_id = $(this).parent().parent().attr('order_goods_id');
//            var url = "{php echo $this->createWebUrl('orders',array('op' => 'change_order_goods'))}";
//            $.ajax({
//                type : "post",
//                url : url,
//                data : {'express_no' : express_no, 'order_goods_id' : order_goods_id},
//                success : function(data){
//                    if(data == 111){
////                        location.reload();
//                    }else{
////                            alert(data);
//                    }
//                }
//            });
//        });
//        $(".goods-remark").blur(function(){
//            var goods_remakr = $(this).val();
//            var order_goods_id = $(this).parent().parent().attr('order_goods_id');
//            var url = "{php echo $this->createWebUrl('orders',array('op' => 'change_order_goods'))}";
//            $.ajax({
//                type : "post",
//                url : url,
//                data : {'remark' : goods_remakr, 'order_goods_id' : order_goods_id},
//                success : function(data){
//                    if(data == 111){
////                        location.reload();
//                    }else{
////                            alert(data);
//                    }
//                }
//            });
//        });
        $(".remark").blur(function(){
            var remark = $(this).val();
            var order_id = "{$order['id']}";
            var url = "{php echo $this->createWebUrl('orders',array('op' => 'change_order'))}";
            $.ajax({
                type : "post",
                url : url,
                data : {'remark' : remark , 'order_id' : order_id},
                success : function(data){
                    if(data == 111){
//                        location.reload();
                    }else{
                        alert(data);
                    }
                }
            });
        });
        $(".member-member").click(function(){
            var order_goods_id = $(this).parent().parent().attr('order_goods_id');
            $("#change-goods-id").val(order_goods_id);
            $("#change-type").val('member-member');
            var member_id = "{$member['id']}";
            var url = "{php echo $this->createWebUrl('orders',array('op' => 'get_member_member'))}";
            $.ajax({
                type : "post",
                url : url,
                data : {'member_id' : member_id},
                success : function(data){
                    $("#member-list").html(data);
                }
            });
        });
        $(".get-member").click(function(){
            var order_goods_id = $(this).parent().parent().attr('order_goods_id');
            $("#change-goods-id").val(order_goods_id);
            $("#change-type").val('get-member');
        });
        $(".had_se_pay").click(function(){
            if(confirm("是否确定结算所有代付款？")){
                var order_goods_id = $(this).parent().parent().attr('order_goods_id');
                var url = "{php echo $this->createWebUrl('orders',array('op' => 'change_order_goods'))}";
                $.ajax({
                    type : "post",
                    url : url,
                    data : {'had_se_pay' : true, 'order_goods_id' : order_goods_id},
                    success : function(data){
                        if(data == 111){
                            location.reload();
                        }else{
                            alert(data);
                        }
                    }
                });
            }else{
                location.reload();
            }
        });
        $(".member-key").keyup(function(){
            var key_word = $(this).val();
            var url = "{php echo $this->createWebUrl('orders',array('op' => 'find_member_by_key'))}";
            $.ajax({
                type : "post",
                url : url,
                data : {'key_word' : key_word},
                success : function(data){
                    $("#member-list").html(data);
                }
            });
        });
        $(".order-member").click(function(){
//            $("#change-type").val('get-member');
            $("#change-type").val('order-member');
        });
        $('#finish').on('click', function () {
            $("#save-data").val(2);
            var can = true;
            $('input.goods-numbers').each(function(){
                if($(this).val() == 0){
                    can = false;
                    $(this).val('');
                    $(this).focus();
                }
            });
            if(can){
                $("#form").submit();
            }else{
                alert("还有商品数量未填写！");
                return false;
            }
        });
    });
    //修改数量以及单价的时候，自动计算运费，代付款
    function get_price(){
        var goods_ids = {$goods_ids};
        var goods_count = '{$goods_count}';
        var goods_count = parseInt(goods_count);
        var total_number = 0;
        var total_freight = 0;
        var total_gen = 0;
        var total_need = 0;
        var had_gen = parseFloat({$had_gen_pay_total});
        var had_freight = parseFloat({$had_freight_total});
        for(var i = 0; i < goods_count; i++){
            var number = $("#number"+i).val();
            var freight = $("#freight"+i).val();
            var gen = $("#gen_pay"+i).val();
            var had_freight_a = parseFloat($("#had-freight"+goods_ids[i]).val());
            number = parseInt(number);
            freight = parseInt(freight);
            gen = parseInt(gen);
            if(had_freight_a > 0){
                had_freight += had_freight_a;
            }
            if(number >= 0) {
                total_number += number;
                if(freight >= 0){
                    total_freight += freight*number;
                }
            }
            if(gen >= 0) {
                total_gen += gen;
            }
        }
        total_need = total_freight + total_gen - had_gen - had_freight;
        $("#t-had-freight").val(had_freight);
        $("#total_numbers").val(total_number);
        $("#total_freight").val(total_freight);
        $("#total_gen").val(total_gen);
        $("#total-need").val(total_need);
    }
    function change_from_member(member_name){
        var goods_id = $("#change-goods-id").val();
        var change_type = $("#change-type").val();
        if(change_type == "member-member"){
            $("#member-member"+goods_id).val(member_name);
        }else if(change_type == "get-member"){
            $("#get-member"+goods_id).val(member_name);
        }else if(change_type == "get-name"){
            $("#get-name"+goods_id).val(member_name);
        }else if(change_type == 'order-member'){
            $("#order-member").val(member_name);
            $(".get-name").val(member_name);
            $(".get-member").val(member_name);
        }
        $("#close").click();
//        if(member_id > 0 && goods_id > 0){
//            var url = "{php echo $this->createWebUrl('orders',array('op' => 'change_order_goods'))}";
//            var change_type = $("#change-type").val();
//            if(change_type == "member-member") {
//                $.ajax({
//                    type: "post",
//                    url: url,
//                    data: {'from_member_id': member_id, 'order_goods_id': goods_id},
//                    success: function (data) {
//                        if (data == 111) {
//                            location.reload();
//                        } else {
////                            alert(data);
//                        }
//                    }
//                });
//            }else if(change_type == "get-member"){
//                $.ajax({
//                    type: "post",
//                    url: url,
//                    data: {'member_id': member_id, 'order_goods_id': goods_id},
//                    success: function (data) {
//                        if (data == 111) {
//                            location.reload();
//                        } else {
////                            alert(data);
//                        }
//                    }
//                });
//            }else if(change_type == "get-name"){
//                $.ajax({
//                    type: "post",
//                    url: url,
//                    data: {'get_member_id': member_id, 'order_goods_id': goods_id},
//                    success: function (data) {
//                        if (data == 111) {
//                            location.reload();
//                        } else {
////                            alert(data);
//                        }
//                    }
//                });
//            }
//        }
    }
</script>
<ul class="nav nav-tabs">
    <li class="active"><a href="{php echo $this->createWebUrl('orders', array('op'=>'index'))}">订单列表</a></li>
    <li ><a href="{php echo $this->createWebUrl('orders', array('op'=>'add'))}">新建订单</a></li>
    <li ><a href="{php echo $this->createWebUrl('orders', array('op'=>'system'))}">待付款手续费设置</a></li>
</ul>
<div class="main">
    <form method="post" action="{php echo $this->createWebUrl('orders',array('op' => 'goods_post'))}" id="form" >
    <div class="panel panel-primary">
        <div class="panel-body">
            <div class="row">
                <div class="col-xs-3">
                    <label class="col-xs-12 col-sm-4 col-md-4 control-label">客户</label>
                    <div class="col-sm-8 col-xs-12">
                        <input type="text" id="order-member" name="order_member" class="form-control order-member" value="{$member['name']}" readonly="readonly" {if $order['status'] == 1}data-toggle="modal" data-target="#myModal"{/if} />
                    </div>
                    <!-- 修改客户 -->
                    <!-- Modal -->
                    <!--<div class="modal fade" id="member" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">-->
                        <!--<div class="modal-dialog" role="document">-->
                            <!--<div class="modal-content">-->
                                <!--<div class="modal-header">-->
                                    <!--<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>-->
                                    <!--<h4 class="modal-title" id="memberLabel">搜索客户</h4>-->
                                <!--</div>-->
                                <!--<div class="modal-body">-->
                                    <!--<div>-->
                                        <!--<input type="text" placeholder="输入客户名称/助记码/电话" class="form-control order-member" />-->
                                    <!--</div>-->
                                    <!--<div >-->
                                        <!--<table class="table" id="order-member-list">-->

                                        <!--</table>-->
                                    <!--</div>-->
                                <!--</div>-->
                                <!--&lt;!&ndash;<div class="modal-footer">&ndash;&gt;-->
                                    <!--&lt;!&ndash;<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>&ndash;&gt;-->
                                    <!--&lt;!&ndash;<button type="button" class="btn btn-primary">Save changes</button>&ndash;&gt;-->
                                <!--&lt;!&ndash;</div>&ndash;&gt;-->
                            <!--</div>-->
                        <!--</div>-->
                    <!--</div>-->
                </div>
                <div class="col-xs-3">
                    <label class="col-xs-12 col-sm-4 col-md-4 control-label">日期</label>
                    <div class="col-sm-8 col-xs-12">
                        <input type="date" class="form-control" name="order_day" value="{$order['day']}" {if $order['status'] == 2} readonly="readonly" {/if} />
                    </div>
                </div>
                <div class="col-xs-3">
                    <label class="col-xs-12 col-sm-4 col-md-4 control-label">单号</label>
                    <div class="col-sm-8 col-xs-12">
                        <input type="text" class="form-control" value="{$order['order_no']}" readonly="readonly" />
                    </div>
                </div>
                <div class="col-xs-3">
                    <label class="col-xs-12 col-sm-4 col-md-4 control-label">客户区域</label>
                    <div class="col-sm-8 col-xs-12">
                        <select class="form-control" disabled="disabled">
                            {loop $regions $region}
                            <option value="{$region['id']}" {if $region['id'] == $member['region_id']} selected="selected" {/if}>{$region['name']}</option>
                            {/loop}
                        </select>
                    </div>
                </div>
            </div>
            <br />
            <div class="row">
                <div class="col-xs-3">
                    <label class="col-xs-12 col-sm-4 col-md-4 control-label">电话</label>
                    <div class="col-sm-8 col-xs-12">
                        <input type="text" class="form-control" value="{$member['phone']}" readonly="readonly" />
                    </div>
                </div>
                <div class="col-xs-3">
                    <label class="col-xs-12 col-sm-4 col-md-4 control-label">总件数</label>
                    <div class="col-sm-8 col-xs-12">
                        <input type="text" class="form-control" value="{$goods_total}" id="total_numbers" readonly="readonly" />
                    </div>
                </div>
                <div class="col-xs-3">
                    <label class="col-xs-12 col-sm-4 col-md-4 control-label">总运费</label>
                    <div class="col-sm-8 col-xs-12">
                        <input type="text" class="form-control" value="{$freight_total}" id="total_freight" readonly="readonly" />
                    </div>
                </div>
                <div class="col-xs-3">
                    <label class="col-xs-12 col-sm-4 col-md-4 control-label">货到区域</label>
                    <div class="col-sm-8 col-xs-12">
                        <select class="form-control" name="order_region" {if $order['status'] == 2} disabled="disabled" {/if}>
                        {loop $regions $region}
                        <option value="{$region['id']}" {if $region['id'] == $order['order_region']} selected="selected" {/if}>{$region['name']}</option>
                        {/loop}
                        </select>
                    </div>

                </div>

            </div>
            <br />
            <div class="row">
                <div class="col-xs-3">
                    <label class="col-xs-12 col-sm-4 col-md-4 control-label">已收运费</label>
                    <div class="col-sm-8 col-xs-12">
                        <input type="text" id="t-had-freight" class="form-control" value="{$had_freight_total}" readonly="readonly" />
                    </div>
                </div>
                <div class="col-xs-3">
                    <label class="col-xs-12 col-sm-4 col-md-4 control-label">已收代付款</label>
                    <div class="col-sm-8 col-xs-12">
                        <input type="text" class="form-control" id="t-had-gen" value="{$had_gen_pay_total}" readonly="readonly" />
                    </div>
                </div>
                <div class="col-xs-3">
                    <label class="col-xs-12 col-sm-4 col-md-4 control-label">应收</label>
                    <div class="col-sm-8 col-xs-12">
                        <input type="text" class="form-control" id="total-need" value="{$need_get_total}" readonly="readonly" />
                    </div>
                </div>
                <div class="col-xs-3">
                    <label class="col-xs-12 col-sm-4 col-md-4 control-label">实收</label>
                    <div class="col-sm-8 col-xs-12">
                        <input type="text" class="form-control" value="{$had_get_total}" readonly="readonly" />
                    </div>
                </div>
            </div>
            <br />
            <div class="row">
                <!--<div class="col-xs-3">-->
                    <!--<label class="col-xs-12 col-sm-4 col-md-4 control-label">代付款</label>-->
                    <!--<div class="col-sm-8 col-xs-12">-->
                        <!--<input type="text" class="form-control" value="{$gen_pay_total}" readonly="readonly" />-->
                    <!--</div>-->
                <!--</div>-->
                <!--<div class="col-xs-3">-->
                    <!--<label class="col-xs-12 col-sm-4 col-md-4 control-label">代收款</label>-->
                    <!--<div class="col-sm-8 col-xs-12">-->
                        <!--<input type="text" class="form-control" value="{$gen_get_total}" readonly="readonly" />-->
                    <!--</div>-->
                <!--</div>-->

                <!--</div> <div class="col-xs-3">-->
                <!--<label class="col-xs-12 col-sm-4 col-md-4 control-label">手续费</label>-->
                <!--<div class="col-sm-8 col-xs-12">-->
                    <!--<input type="text" class="form-control" value="{$charge_total}" readonly="readonly" />-->
                <!--</div>-->
                <!--<div class="col-xs-3">-->
                    <!--<label class="col-xs-12 col-sm-4 col-md-4 control-label">应收金额</label>-->
                    <!--<div class="col-sm-8 col-xs-12">-->
                        <!--<input type="text" class="form-control" value="{$need_get_total}" readonly="readonly" />-->
                    <!--</div>-->
                <!--</div>-->
            </div>
            <br />
            <div class="row">
                <!--<div class="col-xs-3">-->
                    <!--<label class="col-xs-12 col-sm-4 col-md-4 control-label">已收代付款</label>-->
                    <!--<div class="col-sm-8 col-xs-12">-->
                        <!--<input type="text" class="form-control" value="{$had_gen_pay_total}" readonly="readonly" />-->
                    <!--</div>-->
                <!--</div>-->
                <!--<div class="col-xs-3">-->
                    <!--<label class="col-xs-12 col-sm-4 col-md-4 control-label">已收代收款</label>-->
                    <!--<div class="col-sm-8 col-xs-12">-->
                        <!--<input type="text" class="form-control" value="{$had_gen_get_total}" readonly="readonly" />-->
                    <!--</div>-->
                <!--</div>-->
                <!--<div class="col-xs-3">-->
                    <!--<label class="col-xs-12 col-sm-4 col-md-4 control-label">已收手续费</label>-->
                    <!--<div class="col-sm-8 col-xs-12">-->
                        <!--<input type="text" class="form-control" value="{$had_charge_total}" readonly="readonly" />-->
                    <!--</div>-->
                <!--</div>-->
                <!--<div class="col-xs-3">-->
                    <!--<label class="col-xs-12 col-sm-4 col-md-4 control-label">实收金额</label>-->
                    <!--<div class="col-sm-8 col-xs-12">-->
                        <!--<input type="text" class="form-control" value="{$had_get_total}" readonly="readonly" />-->
                    <!--</div>-->
                <!--</div>-->
            </div>
            <div class="row">
                <div class="col-xs-3">
                    <label class="col-xs-12 col-sm-4 col-md-4 control-label">代付款</label>
                    <div class="col-sm-8 col-xs-12">
                        <input type="text" class="form-control" value="{$gen_pay_total}" id="total_gen" readonly="readonly" />
                    </div>
                </div>

                <div class="col-xs-6">
                    <label class="col-xs-12 col-sm-3 col-md-1 control-label">备注</label>
                    <div class="col-sm-9 col-xs-12">
                        <input type="text" class="form-control" name="order_remark" value="{$order['remark']}"/>
                    </div>
                </div>
                <div class="col-xs-6">
                </div>
            </div>
        </div>
    </div>
    {if $order['status'] == 1 || $order['status'] == -1}
    <a href="{php echo $this->createWebUrl('orders',array('op' => 'order_goods_add','order_id' => $order['id']))}">
        <button type="button" class="btn btn-default add-goods">增加商品</button>
    </a>
    <br />
    {/if}

        <input type="hidden" value="" id="number_key" />
        <input type="hidden" value="" id="freight_key" />
        <input type="hidden" name="order_id" value="{$order['id']}"  />
        <table class="table">
            <tr>
                <th>商品</th>
                <!--<th>单位</th>-->
                <th>数量</th>
                <th>运费单价</th>
                <th>代付款</th>
                <th>已收运费</th>
                <!--<th>手续费</th>-->
                <!--<th>到达区域</th>-->
                <!--<th>收款员</th>-->
                <!--<th>已收运费</th>-->
                <th>寄货客户</th>
                <!--<th>收货人</th>-->
                <th>付款客户</th>

                <th>备注</th>
                <th>操作</th>
            </tr>
            {loop $order_goods $key $goods}
            <tr  order_goods_id="{$goods['id']}">
                <td>{$goods['goods_name']}</td>
                <td>
                    <input type="text" value="{if $goods['numbers'] > 0}{$goods['numbers']}{/if}" key="{$key}" id="number{$key}" class="form-control goods-numbers number{$goods['id']}" name="numbers{$goods['id']}" {if $goods['status'] == 2 || $order['status'] == 2} readonly="readonly" {/if}  onfocus="this.select()"/>
                </td>
                <td>
                    <input type="text" value="{$goods['freight']}" class="form-control freight fre{$goods['id']}" key="{$key}" id="freight{$key}" name="freight{$goods['id']}" {if $goods['status'] == 2 || $order['status'] == 2} readonly="readonly" {/if} onfocus="this.select()"/>
                </td>
                <td>
                    <input type="text" value="{if $goods['gen_pay'] > 0}{$goods['gen_pay']}{/if}" id="gen_pay{$key}" name="gen_pay{$goods['id']}" class="form-control gen-pay" id="gen_pay{$key}" {if $goods['status'] == 2 || $order['status'] == 2} readonly="readonly" {/if} />
                </td>
                <td>
                    {if $goods['had_freight'] == null}
                    <input type="text" value="{$goods['had_freight']}" id="had-freight{$goods['id']}" name="had_freight{$goods['id']}" class="form-control had-freight" />
                    {else}
                    {$goods['had_freight']}
                    {/if}
                </td>
                <!--<td>-->
                    <!--<select class="form-control goods-region" name="region{$goods['id']}" {if $goods['status'] == 2 || $order['status'] == 2 || true} disabled='disabled' {/if}>-->
                        <!--{loop $regions $region}-->
                        <!--<option value="{$region['id']}" {if $region['id'] == $goods['region_id']} selected="selected" {/if}>{$region['name']}</option>-->
                        <!--{/loop}-->
                    <!--</select>-->
                <!--</td>-->
                <!--<td>-->
                    <!--<select class="form-control cashier" name="cashier{$goods['id']}" {if $goods['status'] == 2 || $order['status'] == 2} disabled='disabled' {/if}>-->
                        <!--<option value="0">未有收款员</option>-->
                        <!--{loop $all_users $user}-->
                        <!--<option value="{$user['uid']}" {if $user['uid'] == $goods['cashier']} selected="selected" {/if}>{$user['username']}</option>-->
                        <!--{/loop}-->
                    <!--</select>-->
                <!--</td>-->
                <td>
                    {if $goods['from_member']}
                    <input type="text" value="{$goods['from_member']['name']}" name="from_member{$goods['id']}" id="member-member{$goods['id']}" class="form-control member-member" readonly="readonly" {if $goods['status'] == 1}data-toggle="modal" data-target="#myModal" {/if} />
                    {else}
                    <input type="text" value="点击添加" id="member-member{$goods['id']}" name="from_member{$goods['id']}" class="form-control member-member" readonly="readonly" data-toggle="modal" data-target="#myModal" {if $goods['status'] == 1}data-toggle="modal" data-target="#myModal" {/if} />
                    {/if}
                </td>
                <!--<td>-->
                    <!--<input type="text" value="{$goods['get_name']}" id="get-name{$goods['id']}" name="get_name{$goods['id']}" class="form-control get-name" readonly="readonly" {if $goods['status'] == 1}data-toggle="modal" data-target="#myModal" {/if} />-->
                <!--</td>-->
                <td>
                    <input type="text" value="{$goods['member']['name']}" id="get-member{$goods['id']}" name="get_member{$goods['id']}" readonly="readonly" class="form-control get-member" {if $goods['status'] == 1}data-toggle="modal" data-target="#myModal" {/if}/>
                </td>

                <td>
                    <input type="text" class="form-control goods-remark" value="{$goods['remark']}" name="remark{$goods['id']}" {if $goods['status'] == 2} readonly="readonly" {/if} />
                </td>
                <td>
                    {if $goods['had_se_pay'] == 0}
                    {/if}
                    {if $goods['status'] <= 1 }
                    <!--<button type="button" class="btn btn-primary get-money">收齐</button>-->
                    <button type="button" class="btn btn-danger del-goods">删除</button>
                    {/if}
                </td>
            </tr>
            {/loop}

        </table>
        <div>
            <input type="hidden" value="1" id="save-data" />
            <button type="button" class="btn btn-primary" id="finish">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;保存&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</button>
            <a href="{php echo $this->createWebUrl('orders')}"><button type="button" class="btn btn-danger">取消</button></a>
            {if $order['status'] <= 1 && $goods['had_freight'] == 0}
            <button type="button" class="btn btn-success get-all-money" style="float: right;">全部收齐</button>
            {/if}
        </div>
    </form>
</div>

<!-- 修改寄货人 -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" id="close" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">双击选择</h4>
            </div>
            <div class="modal-body">
                <div style="width:30%" align="center">
                    <input type="text" class="form-control member-key" placeholder="客户名称/助记码"  />
                </div>
                <br />
                <table class="table" id="member-list">
                </table>
                <input type="hidden" id="change-goods-id" value="0" />
                <input type="hidden" id="change-type" value="" />
            </div>
        </div>
    </div>
</div>

{template 'common/footer'}